/*
	@file: log/source/LogStream.cpp
	@author: Wolfhead
*/
#include "LogStream.h"
#include "Log.h"

namespace logger
{

LogStream::LogStream(LogPriority priority, LogContext context)
	: m_data_ptr(new LogData(context))
{
	m_data_ptr->priority = priority;
	m_data_ptr->byname = false;
}

LogStream::LogStream(const std::string& name, LogContext context)
	: m_data_ptr(new LogData(context))
{
	m_data_ptr->priority = kName;
	m_data_ptr->byname = true;
	m_data_ptr->name = name;
}

LogStream::~LogStream()
{
	if (priority_is_set())
	{
		m_data_ptr->message = m_stream.str();
		get_log_dispatcher().log(m_data_ptr);
	}
}

bool LogStream::priority_is_set()
{
	return (get_log_dispatcher().get_aggregate_priority() & m_data_ptr->priority);
}


}//namespace logger
